package com.ganee.agora.repository

import com.ganee.agora.api.MainApiService
import com.ganee.agora.model.FileEntity
import com.ganee.agora.model.UserInfoEntity
import com.ganee.baselib.httprequest.callback.RequestCallback
import com.ganee.baselib.mvvmlibrary.base.BaseRepository
import com.ganee.baselib.mvvmlibrary.base.BaseViewModel

import okhttp3.RequestBody

class ProfileRepository(baseViewModel: BaseViewModel<*>) : BaseRepository(baseViewModel) {

    /**
     * 获取用户信息
     */
    fun getUserInfo(callback: RequestCallback<UserInfoEntity>) {
        execute(getApi(MainApiService::class.java).postUserInfo(), callback)
    }

    /**
     * 更新用户信息
     */
    fun updateUserInfo(body: RequestBody, callback: RequestCallback<UserInfoEntity>) {
        execute(getApi(MainApiService::class.java).updateUserInfo(body), callback)
    }

    /**
     * 获取头像
     */
    fun downloadUserPic(callback: RequestCallback<String>) {
        executeQuietly(getApi(MainApiService::class.java).downloadUserPic(), callback)
    }

    /**
     * 更新头像
     */
    fun uploadUserPic(body: RequestBody, callback: RequestCallback<String>) {
        executeQuietly(getApi(MainApiService::class.java).uploadUserPic(body), callback)
    }
    /**
     * 更新头像
     */
    fun uploadFile(body: RequestBody, callback: RequestCallback<FileEntity>) {
        executeQuietly(getApi(MainApiService::class.java).postUploadFile(body), callback)
    }
}
